package com.eternal.Exception;

import lombok.Data;

/**
 * HTTP返回外层结果对象
 *
 * @param <T>
 */
@Data
public class ResultVo<T> {
    /**
     * 错误码
     */
    private String code;
    /**
     * 提示信息
     */
    private String message;
    /**
     * 返回结果
     */
    private T data;

    public ResultVo(T data) {
        this.code = "0";
        this.message = "success";
        this.data = data;
    }

    public ResultVo(ResultEnum resultEnum){
        this.code = resultEnum.getCode();
        this.message=resultEnum.getMessage();
    }

    public ResultVo(ResultEnum resultEnum,T data){
        this.code = resultEnum.getCode();
        this.message=resultEnum.getMessage();
        this.data=data;
    }

    public ResultVo(String msg){
        this.code = "-1";
        this.message = msg;
    }

    public ResultVo(String code, String msg) {
        this.code = code;
        this.message = msg;
    }

    public ResultVo(String code, String msg, T data) {
        this.code = code;
        this.message = msg;
        this.data = data;
    }

    public ResultVo() {
        this.code = "0";
        this.message = "success";
    }


}
